class Solution:
    def longestSubstring(self, s: str, k: int) -> int:
        for alpha in set(s):
            if s.count(alpha) < k:
                return max(self.longestSubstring(mid_s, k) for mid_s in s.split(alpha))
        return len(s)


a = Solution()
print(a.longestSubstring("weitong", 2))
